<template>
  <div>
    <div class="flexrowbetween flexwrapper" style="align-items: flex-start">
      <!-- <div class="iconbox flexcenter commhover blackbg" @click="resetQuery">
        <i class="el-icon-refresh f-20" :class="{'rotate':isrefresh}"></i>
      </div> -->
      <div>
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          label-width="0"
        >
          <el-form-item prop="status1">
            <el-select
              v-model="queryParams.status"
              placeholder="核销状态"
              style="width: 120px"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="status2">
            <el-select
              v-model="queryParams.status2"
              placeholder="物流状态"
              style="width: 120px"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="status3">
            <el-select
              v-model="queryParams.status3"
              placeholder="选择核销员"
              style="width: 120px"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="day">
            <el-radio-group v-model="queryParams.day">
              <el-radio-button v-for="(item,index) in daylist" :label="item.value" :key="index">{{item.name}}</el-radio-button>
            </el-radio-group>
          </el-form-item>
          <el-form-item prop="day">
            <el-date-picker
              v-model="times"
              type="datetimerange"
              value-format="yyyy-MM-dd HH:mm:ss"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button
              class="f-14"
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
            >查询</el-button>
          </el-form-item>
          <el-form-item prop="code">
            <el-input style="width:120px"
              class="searchinput"
              v-model="queryParams.code"
              placeholder="请输入券码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <!-- <el-form-item class="mr_0">
            <el-dropdown trigger="click">
                <el-button size="mini" class="nor_border plr_9">
                  <svg-icon class-name="f-14" icon-class="listicon" />
                  <i class="el-icon-caret-bottom el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown">
                    <div class="dropbody">
                      <el-checkbox-group v-model="checkedOption" class="flexcolumn" @change="changeSelect">
                        <el-checkbox v-for="(item,index) in selectoptions" :label="item.label" :key="index" class="m_5">{{item.label}}</el-checkbox>
                      </el-checkbox-group>
                    </div>
                </el-dropdown-menu>
            </el-dropdown>
          </el-form-item>
          <el-form-item>
            <el-dropdown trigger="click" @command="handleCommand">
                <el-button size="mini" class="nol_border plr_9">
                  <svg-icon class-name="f-14" icon-class="export" />
                  <i class="el-icon-caret-bottom el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="(item,index) in exportlist" :key="index" :command="item.id">{{item.name}}</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
          </el-form-item> -->
          <el-form-item>
            <el-button
              class="f-14"
              type=""
              size="mini"
              @click="handleQuery"
            >导出</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <el-table
      v-loading="loading"
      :data="list"
      border
      ref="tablelayout"
      class="commtable"
    >
      <!-- <el-table-column label="" prop="search_engine" width="80" align="center">
          <template slot-scope="scope">
            <el-popover
                placement="bottom-start"
                width="120"
                trigger="hover">
                <img src="@/assets/images/icon1.png" class="imgbox"/>
                <img src="@/assets/images/icon1.png" class="imgmini" slot="reference" />
            </el-popover>
          </template>
        </el-table-column> -->
      <el-table-column label="平台" prop="platName" width="120" align="center">
        <template slot-scope="scope">
          {{ scope.row.platName }} 智选评选
        </template>
      </el-table-column>
      <el-table-column label="活动分类" width="120" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.activeid }} 抽奖</span>
        </template>
      </el-table-column>
      <el-table-column
        label="活动名称"
        prop="name"
        width="200"
        align="center"
      />
      <el-table-column
        label="活动编号"
        prop="name"
        width="100"
        align="center"
      />
      <el-table-column
        label="核销时间"
        prop="time"
        width="200"
        align="center"
      />
      <el-table-column label="核销员" prop="time" width="200" align="center" />
      <el-table-column label="卷码" prop="time" width="200" align="center" />
      <el-table-column
        label="核销方式"
        prop="time"
        width="200"
        align="center"
      />
      <el-table-column
        label="奖项等级"
        prop="time"
        width="200"
        align="center"
      />
      <el-table-column
        label="奖品名称"
        prop="time"
        width="200"
        align="center"
      />
      <el-table-column label="中奖者" prop="time" width="200" align="center" />
      <el-table-column label="核销状态" align="center">
        <template slot-scope="scope">
          <el-tag type="success" class="tag_success"
            >{{ scope.row.status }}已核销</el-tag
          >
          <!-- <el-tag type="danger" class="tag_danger">已结束</el-tag>
            <el-tag type="info" class="tag_info">未发布</el-tag>
            <el-tag type="warning" class="tag_warning">已结束</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="物流状态" align="center">
        <template slot-scope="scope">
          <el-tag type="success" class="tag_success"
            >{{ scope.row.status }}已发货</el-tag
          >
          <!-- <el-tag type="danger" class="tag_danger">已结束</el-tag>
            <el-tag type="info" class="tag_info">未发布</el-tag>
            <el-tag type="warning" class="tag_warning">已结束</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="物流信息" width="220" align="center" fixed="right">
        <template slot-scope="scope">
          <div class="flex">
            <div
              class="commhover btn_green mr_10 c_fff"
              @click="handleAdd(scope.row)"
            >
              <svg-icon icon-class="fabu" class-name="f-14" /> 添加物流单
            </div>
            <div
              class="commhover btn_blue c_fff"
              @click="handleDetail(scope.row)"
            >
              <svg-icon icon-class="fabu" class-name="f-14" /> 详情
            </div>
            <!-- <div
              class="commhover btn_green mr_10 c_fff"
              @click="handleFabu(scope.row)"
            >
              <svg-icon icon-class="fabu" class-name="f-14" /> 添加地址
            </div> -->
          </div>
        </template>
      </el-table-column>
      <el-table-column label="备注" width="150" align="center">
        <template slot-scope="scope">
          <span>详情{{ scope.row.status }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.num"
      @pagination="getList"
    />

    <el-dialog
      title="添加物流单"
      :visible.sync="open"
      width="680px"
      class="dialogheaderbg"
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" label-position="left">
        <el-form-item label="快递公司" prop="expressage">
          <el-select
            clearable
            v-model="form.expressage"
            placeholder="请选择快递公司"
            style="width: 100%"
          >
            <el-option
              v-for="(item, index) in kdList"
              :key="index"
              :value="item.value"
              >{{ item.label }}</el-option
            >
          </el-select>
        </el-form-item>
        <el-form-item label="快递单号" prop="order">
          <el-input
            v-model="form.order"
            placeholder="请输入快递单号"
            maxlength="50"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 详情 -->
    <el-dialog
      title="物流详情"
      :visible.sync="detailOpen"
      width="760px"
      class="dialogheaderbg"
      :before-close="handleDetailClose"
    >
      <view-comp :rowId="rowId" @close="handleDetailClose" />
    </el-dialog>
  </div>
</template>
<script>
// import { mapState } from "vuex";
// import FabuComp from "./components/FabuComp.vue";
// import LogTable from "./components/LogTable.vue";
import ViewComp from "./components/ViewComp.vue";
export default {
  data() {
    return {
      queryParams: {
        page: 1,
        num: 10,
        name: undefined,
        day: undefined,
      },
      total: 1,
      loading: false,
      list: [{ id: 1 }, { id: 2 }],
      options: [
        { label: "全部核销状态", value: 0 },
        { label: "已核销", value: 1 },
        { label: "待核销", value: 2 },
        { label: "核销中", value: 3 },
      ],
      daylist: [
        { name: "今天", value: 1 },
        { name: "昨天", value: 2 },
        { name: "最近7天", value: 7 },
        { name: "最近30天", value: 30 },
        { name: "本月", value: 31 },
      ],
      times:'',
      isrefresh: false,
      open: false,
      form:{},
      rules:{
        expressage:[{ required: true, message: "请选择快递公司", trigger: "change" }],
        order:[{ required: true, message: "请输入快递单号", trigger: "blur" }],
      },
      kdList:[{label:"顺丰快递",value:1}],
      detailOpen:false,
      rowId:'',
    };
  },

  props: {
    type: {
      type: Number,
      default: 1,
    },
  },

  components:{
    ViewComp
  },

  created() {
    
  },

  methods: {
    getList() {
      this.loading = true;
      let params = { ...this.queryParams };
      //   if(this.queryParams.type=='创建日期' && this.time && this.time.length){
      //     params.startime = this.time[0]
      //     params.endtime = this.time[1]
      //   }
      //   feedbacklist(params).then((response) => {
      //     this.tableData = response.data.list;
      //     this.total = response.data.count;
      //     this.loading = false;
      //   });
      this.isrefresh = false;
      this.loading = false;
    },

    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },

    resetQuery() {
      this.isrefresh = true;
      this.resetForm("queryForm");
      this.handleQuery();
    },

    changeSelect(arr) {
      this.$store.commit("SET_ACTIVEOPTION", arr);
      this.$nextTick(() => {
        //在数据加载完，重新渲染表格
        this.$refs.tablelayout && this.$refs.tablelayout.doLayout();
      });
    },

    handleCommand(command) {
      console.log(command);
    },

    handleAdd(row) {
      this.open = true;
    },

    handleClose() {
      this.open = false;
    },

    submit(){
      this.$refs.form.validate(valid=>{
        if(!valid) return

      })
    },

    handleDetail(row){
      this.rowId = row.id
      this.detailOpen = true
    },

    handleDetailClose(){
      this.detailOpen = false
    }

  },
};
</script>

<style lang="scss" scoped>
.iconbox {
  width: 32px;
  height: 26px;
}
.imgmini {
  width: 40px;
  height: 40px;
  margin: auto;
}
.imgbox {
  width: 120px;
  height: 120px;
}
</style>
<style lang="scss">
.noheaderdia {
  .el-dialog__header {
    padding: 0 !important;
  }
  .el-dialog__body {
    padding: 0 !important;
  }
}
</style>